package com.dragon.refect.clazz;

import sun.reflect.Reflection;

/**
 *
 *
 * @author dragon
 * @since 2019/11/30
 */
public class ClassDemo1 {

    private String name;

    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException,
            InstantiationException {
        Class<?> personClass = Class.forName("com.dragon.refect.clazz.Person", false,
                ClassDemo1.class.getClassLoader());
        System.out.println("personClass:" + personClass + " personClass classLoader:" + personClass.getClassLoader());

        Class<?> personClazz =  Class.forName("com.dragon.refect.clazz.Person", false,
                ClassLoader.getSystemClassLoader());
        System.out.println("personClazz:" + personClazz + " personClazz classLoader:" + personClazz.getClassLoader());
        System.out.println("personClass 是否等于 personClazz:  " + (personClass == personClazz));
        Object o = personClass.newInstance();
        System.out.println("personInstance:" + o);
    }


    public ClassDemo1(String name) {
        this.name = name;
    }


}
